package com.example.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitmqConfig {

    //配置队列
    @Bean
    public Queue directQueue(){
        return new Queue("direct_queue_ams");
    }

    //配置交换机
    @Bean
    public DirectExchange directExchange(){
        return new DirectExchange("DirectExchange");
    }

    //配置绑定关系
    @Bean
    public Binding binDing(){
        return BindingBuilder.bind(directQueue()).to(directExchange()).with("direct");
    }
}
